package com.example.mapper;

import com.example.entity.Menu;
import org.apache.ibatis.annotations.*;

import java.util.List;


public interface JsMindMapper {


    /**
     * 获取任课教师工号
     *
     * @param book_name
     * @return
     */
    @Select("select teacher_num from tea_choice  where book_name=#{book_name}")
    String GetTeacherNum(String book_name);

    /**
     * 获取教师姓名
     *
     * @param teacher_num
     * @return
     */
    @Select("select name from teachers where num = #{teacher_num}")
    String GetTeacherName(String teacher_num);

    /**
     * 获取课本目录信息
     *
     * @param book_name
     * @return
     */
    @Select("select * from menu where book_name=#{book_name}")
    @Results(value = {
            @Result(column = "id", property = "id"),
            @Result(column = "title", property = "title"),
            @Result(column = "book_name", property = "book_name"),
            @Result(column = "parent_id", property = "parent_id"),
            @Result(column = "direction", property = "direction"),
            @Result(column = "has_content", property = "has_content"),
    })
    List<Menu> GetBookMenu(String book_name);

    /**
     * 添加课程信息
     *
     * @param book_name
     * @return
     */
    @Insert("insert into books values(#{book_name})")
    Integer AddBook(String book_name);


    /**
     * 查询课程是否存在
     *
     * @param book_name
     * @return
     */
    @Select("select * from books where book_name=#{book_name}")
    List<String> FindBookName(String book_name);

    @Update("update menu set has_content='是' where book_name=#{book_name} and topic=#{menu_topic}")
    Integer updateContent(String book_name, String menu_topic);
}
